<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<script>

// The test involves navigating so we use a iframe for the navigation to
// simplify testharness usage in the main page.
function conduct_test(frame) {
  return new Promise(function(resolve, reject) {
      var IFRAME_SRC = "resources/navigate-during-commit-iframe.html"
      var onload_count = 0;
      var frame = document.createElement('iframe');
      frame.onload = function () {
          if (++onload_count == 2) {
              var success = window[0].location == "about:blank";
              document.body.removeChild(frame);
              if (success)
                resolve();
              else
                reject();
          }
        };
      frame.src = IFRAME_SRC;        
      document.body.appendChild(frame);
  });
}

async_test(function(t) {
    var step = t.step_func.bind(t);
    conduct_test()
      .then(step(function() { t.done(); }),
            step(function() { assert_true(false, "promised rejected"); }))
      .catch(step(function() { assert_true(false, "caught exception"); }));
  }, 'navigate-during-commit');

</script>
</body>
